[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 isspace()               Test for White-Space Character (Macro)

 #include   <ctype.h>

 int        isspace(c);
 int        c;                           Integer value to be tested

    isspace() tests whether 'c' is a white-space character; that is, a
    space, a horizontal or vertical tab, a new-line character, a
    form-feed character, or a carriage-return.

       Returns:     Nonzero if the test is true and zero if it is false.
                    The result is undefined if 'c' is not an ASCII
                    character or EOF.

         Notes:     isspace() is a macro.

   -------------------------------- Example ---------------------------------

    The following statements read characters from a file and put each
    word (characters set off by a space) on a separate line.


           #include <ctype.h>
           #include <stdio.h>

           FILE *stream;
           int ch;
           int x = 0;

           main()
           {
               if ((stream = fopen("data.txt","r+")) != NULL) {
                  while (!feof(stream))
                      if(isspace(ch = getc(stream))) {
                             putchar('\n');
                             x = 0;
                      }
                      else
                          putchar(ch);
                  fclose(stream);
               }
           }



See Also: isalnum() isalpha() isascii() isdigit() isgraph()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson